<template>
	<view class="page">
		<view class="head-back">
			<view class="back" @click="onBack">
				<text></text>
			</view>
			<view class="title">
				<text>我的订单</text>
			</view>

		</view>
		<!-- 订单tab -->
		<view class="order-tab">
			<view class="tab" :class="{'action':OrderType==''}" @click="onOrderTab('')">
				<text>全部</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':OrderType==1}" @click="onOrderTab(1)">
				<text>待付款</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':OrderType==2}" @click="onOrderTab(2)">
				<text>待发货</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':OrderType==3}" @click="onOrderTab(3)">
				<text>待收货</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':OrderType==7}" @click="onOrderTab(7)">
				<text>待评价</text>
				<text class="line"></text>
			</view>
		</view>
		<!-- 订单列表 -->
		<view class="order-list">
			<view class="list" v-for="(item,index) in goodsList" @click="onOrderList(item.id)" :key="index">
				<view class="title-status">
					<view class="title">
						<text>下单时间：{{item.create_time}}</text>
					</view>
					<view class="status">
						<text>{{item.statusTxt}}</text>
						<text class="iconfont icon-laji del" v-if="item.status != 2&&item.status != 3"></text>
					</view>
				</view>
				<view class="goods-list">
					<view class="goods">
						<view class="thumb">
							<image :src="item.img_list[0]" mode=""></image>
						</view>
						<view class="item">
							<view class="goods-name">
								<text class="two-omit">{{item.goodsName}}</text>
							</view>
							<view class="goods-price">
								<text class="min">￥</text>
								<text class="max">{{((item.order_price-0)+(item.express_fee-0))}}</text>
								<text class="min">.00</text>
							</view>
						</view>
					</view>
				</view>
				<view class="status-btn">
					<!-- <view class="btn action" v-if="item.status == 2" @click="onOrderList(item.id)">
						<text>去发货</text>
					</view>
					<view class="btn action" v-if="item.status == 7" @click.stop="onEvaluate">
						<text>评价</text>
					</view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getOrderList
	} from '@/config/api.js';
	export default {
		data() {
			return {
				queryList: {
					page: 1,
					limit:20,
					nav_id: uni.getStorageSync('pathNavId'),
					store_id: uni.getStorageSync('pathStoreId'),
					status: '',
				},
				OrderType: 0,
				goodsList: [],
			};
		},
		onLoad(params) {
			this.OrderType = params.type;
			this.queryList.status = params.type;
			getOrderList(this.queryList).then(res => {
				this.goodsList = res.data;
			})
		},
		methods: {
			/**
			 * 返回点击
			 */
			onBack() {
				uni.navigateBack();
			},
			/**
			 * 订单tab点击
			 */
			onOrderTab(type) {
				this.queryList.status = type;
				getOrderList(this.queryList).then(res => {
					this.goodsList = res.data;
				})
				this.OrderType = type;
				// #ifdef H5
				uni.redirectTo({
					url: '/pages/MyOrderList/MyOrderList?type=' + type,
				})
				//#endif
			},
			/**
			 * 订单列表点击
			 */
			onOrderList(id) {
				uni.navigateTo({
					url: '/pages/OrderDetails/OrderDetails?oderId='+id,
				})
			},
			/**
			 * 评价点击
			 */
			onEvaluate() {
				uni.navigateTo({
					url: '/pages/MyEvaluatePush/MyEvaluatePush'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'MyOrderList.scss';
</style>